package fr.umlv.jee.jawp.service.configuration;

import java.util.List;
import org.jawp.persistence.Customer;
import org.jawp.persistence.CustomerDAO;
import org.jawp.persistence.Title;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("CustomerService")
public class CustomerService {
	@Autowired
	private CustomerDAO dao;

	/*************************************
	 *				Creation
	 *************************************/

	@Transactional
	public Customer createNewCustomer(Title title, String firstName, String lastName,
			String adress, String phone, String email) {
		return dao.createNewCustomer(title, firstName, lastName, adress, phone, email);
	}

	/*************************************
	 *				Getter
	 *************************************/

	@Transactional(readOnly = true)
	public List<Customer> getCustomers() {		 
		return dao.getCustomers();
	}

	@Transactional(readOnly = true)
	public Customer getCustomerBy() { //TODO	 
		return null;
	}

	@Transactional(readOnly = true)
	public Customer getCustomerById(int id) {		 
		return dao.getCustomerById(id);
	}

	/*************************************
	 *				Setter
	 *************************************/

	/*************************************
	 *				Deletion
	 *************************************/

	@Transactional
	public void deleteCustomer(int id) {
		dao.deleteCustomer(id);
	}
}
